home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / tsr.swg / 0021_Clock 2.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-01-27  |  2.5 KB  |  63 lines

  1. {
  2. > H E L P!!!  I need help with the timer Interrupt... I guess?  Here
  3. > is what I would like to do, I want to have the Time in the upper right
  4. > hand corner updated by the second.  I was told that I need to "hook in
  5. > to the timmer interrupt" but, how do I do that?  Any help would be
  6. > appreciated.  And if possible make it as non technical as possable.
  7.  
  8. Here is just the program your looking for!
  9. }
  10. Program Clock_demo;
  11. {$M $400 ,0 ,0}                       { Stack Size $400 , No Heap      }
  12. {$F+}
  13. Uses Dos ,Crt;
  14. Var
  15.     Count:Byte;                       { Counts Seconds                }
  16.     Time:Longint  Absolute $40:$6C;   { Bios Keeps Clock Time Here    }
  17.     Old1Cint:Procedure;               { Linkage To Old 1C Interrupt   }
  18.  
  19.  
  20. { Every 18 Pulses Shows Time At The Left Corner Of Screen }
  21. Procedure Get_Time;Interrupt;
  22. Var X ,Y:Byte;
  23.     Hour ,Minute ,Sec:Word;
  24. Begin
  25.   Inc(Count);
  26.   If Count =18 Then                        { Every Second 18.2 Pulses      }
  27.     Begin
  28.       Count:=0;
  29.       X:=Wherex;                           { Save Cursor Place             }
  30.       Y:=Wherey;
  31.       Hour:=Time Div 65520;                { Calculate Hours. In Each Hour }
  32.                                            { 18.2 * 60 * 60 Pulses         }
  33.       Minute:=Time Mod 65520 Div 1092;     { Calculate Minutes. In Each    }
  34.                                            { Minute 18.2 * 60 Pulses       }
  35.       Sec:=Round((Time Mod 65520 Mod 1092) / 18.2) Mod 60; { Seconds       }
  36.       Gotoxy(70 ,1);                       { Left Corner Of Screen         }
  37.                                            { Write time                    }
  38.       If Hour<10 Then
  39.         Write(0,Hour,':')
  40.       Else
  41.         Write(Hour,':');
  42.       If Minute<10 Then
  43.         Write(0,Minute,':')
  44.       Else
  45.         Write(Minute,':');
  46.       If Sec<10 Then
  47.         Write(0,Sec)
  48.       Else
  49.         Write(Sec);
  50.       Gotoxy(X ,Y);                        { Restore Cursor Position       }
  51.     End;
  52.   Inline($9C);                             { Pushf - Push Flags            }
  53.   Old1Cint;                                { Link Old 1C Procedure         }
  54. End;
  55.  
  56. Begin                          { Of Main Program                     }
  57.   Count:=0;                    { Clock Pulses Counter                }
  58.   Getintvec($1C ,@Old1Cint);   { Save Old 1C Interrupt Vector        }
  59.   Setintvec($1C ,@Get_Time);   { Insert Current Interurupt Procedure }
  60.   Keep(0);                     { Terminate And Stay Resident - Tsr   }
  61. End.
  62.  
  63.